let OSS = require('ali-oss')
export function client(obj) {
    return new OSS({
        // region: 'oss-cn-shenzhen',
        // accessKeyId: 'LTAI4G4Mnvqnc8S1imXnEgao',
        // accessKeySecret: 'MgJMaZ1dZU39pAG4FrwRPvSeTNTVzO',
        // bucket: 'juguo-bucket'
        region: 'oss-cn-shenzhen',
        accessKeyId: obj.AccessKeyId,
        accessKeySecret: obj.AccessKeySecret,
        bucket: 'smart-glasses',
        stsToken:obj.SecurityToken,
    })
}

/**
 * 生成随机文件名称
 * 规则八位随机字符，加下划线连接时间戳
 */
export const getFileNameUUID = () => {
    function rx() {
        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
    }
    return `${+new Date()}_${rx()}${rx()}`
}